package com.edushare.common.vo;

import java.util.ArrayList;
import java.util.List;

import com.edushare.common.constants.DefaultFiles;
import com.edushare.common.vo.FileDirectories.DIRECTORY_OWNER_TYPE;
import com.edushare.common.vo.auto._Universities;
import com.edushare.common.vo.interfaces.IFileUploadable;

public class Universities extends _Universities implements 
	IFileUploadable, EduShareEntity, NameComparision{

	private static final long serialVersionUID = -4046108756629291801L;	
	public static final int UNIV_STATUS_INACTIVE = 0;
	public static final int UNIV_STATUS_ACTIVE = 1;
		
	public static final int UNIV_SCHEDULE_SEMESTER_CHANGE = 8;
	public static final int UNIV_ALLOW_ELECTIVE_SELECTION = 10;
	public static final int UNIV_LOCK_ELECTIVE_SELECTION  = 15;
	public static final int UNIV_CLOSE_ELECTIVE_SELECTION = 20;
	
	
	public Universities(){
		setElectiveSelectionTime(UNIV_ALLOW_ELECTIVE_SELECTION);
		setSettings("zms:qd;zmv:qd;zcv:qd;zcc:qc;");
	}
	
	public List<Departments> getDeptFilteredByOwnership(int universityDepartmentLinkType){
		List<UnivDeptLink> udl =  super.getDeptLinks();
		List<Departments> deptList = new ArrayList<Departments>();
		for(UnivDeptLink ud:udl){
			deptList.add(ud.getDepartment());
		}
		return deptList;
	}
	
	/** IFileUploadable implementation Starts */
	public String getUploadedFileUrl() {
		if(getImageFile()==null){
			return DefaultFiles.getDefaultImageFileUrl(this);
		}
		return getImageFile().getFileDownloadUrl();
	}

	public DIRECTORY_OWNER_TYPE getObjectType() {
		return DIRECTORY_OWNER_TYPE.UNIVERSITY;
	}
	
	public int getObjectPrimaryKey() {
		return getUniversityId();
	}

	public String getTitle() {
		return getUniversityName();
	}

	public String getName() {
		return getUniversityName();
	}

	public int compareTo(INameComparable o) {
		return getName().compareTo(o.getName());
	}
	
	/** IFileUploadable implementation Starts */
	
}
